package com.zgkxzx.mvvmbase.viewmodel;

import android.content.Context;
import android.databinding.BindingAdapter;
import android.databinding.Observable;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.zgkxzx.mvvmbase.bean.picture.PictureBean;

import java.lang.ref.WeakReference;


/**
 * 创建者 zgkxzx
 * 日期   2/1/18
 * 描述
 */

public class ItemViewModel extends BaseViewModel {
    private static final String TAG = ItemViewModel.class.getSimpleName();

    PictureBean pictureBeanData;


    public ItemViewModel(Context context, PictureBean pictureBean) {
        super(context);
        this.pictureBeanData = pictureBean;
    }


    public void onItemClickEvent(View view) {
        Log.d(TAG, "onItemClickEvent " + pictureBeanData);
    }


    public void setPictureBeanData(PictureBean pictureBeanData) {
        this.pictureBeanData = pictureBeanData;
    }


    public String getTitle() {
        return pictureBeanData.getDesc();
    }


    public String getUrl() {
        return pictureBeanData.getUrl();
    }


    @BindingAdapter("averUrl")
    public static void setUrlImg(ImageView imageView, String url) {
        Glide.with(contextRef.get())
                .load(url)
                .centerCrop()
                .into(imageView);
    }

    @Override
    public void onCreate() {

    }

    @Override
    public void onDestroy() {

    }
}
